package com.kfm.model;

import com.kfm.model.group.AccountGroupForSave;
import com.kfm.model.group.AccountGroupForUpdate;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;

@Data
public class Account implements Serializable {

    @NotNull(message = "id 不能为 空", groups = {AccountGroupForUpdate.class})
    private Integer id;

    @NotNull(groups = {AccountGroupForUpdate.class, AccountGroupForSave.class})
    @Length(min = 2, groups = {AccountGroupForUpdate.class, AccountGroupForSave.class})
    private String name;

    @Length(min = 6, max = 20, message = "【用户名 的长度需要在 6 ~ 20 之间】", groups = {AccountGroupForUpdate.class, AccountGroupForSave.class})
    private String username;

    @Length(min = 6, max = 20, groups = {AccountGroupForUpdate.class, AccountGroupForSave.class})
    private String password;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date createDate;
}

